//
//  TBCPermissionCell.m
//  待定
//
//  Created by BoyaLee on 15/11/10.
//  Copyright © 2015年 BoyaLee. All rights reserved.
//

#import "TBCPermissionCell.h"

@interface TBCPermissionCell () <UIWebViewDelegate>

@property (strong, nonatomic) UIWebView *contentWV;

@end

@implementation TBCPermissionCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self initPermissionCellViews];
        
    }
    
    return self;
    
}

- (void)initPermissionCellViews {
    
    [self setBackgroundColor:[UIColor whiteColor]];
    
    self.contentWV = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, WIDTH - 20, 180)];
    self.contentWV.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic;
    self.contentWV.backgroundColor = [UIColor whiteColor];
    self.contentWV.delegate = self;
    self.contentWV.scalesPageToFit = YES;
    [self addSubview:_contentWV];
    
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '300%'"];
    
}

- (void)setFileName:(NSString *)fileName {
    
    _fileName = fileName;
    
    NSString * filePath = [[NSBundle mainBundle] pathForResource:[self fileName] ofType:@".html"];
    NSString * htmlStr = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
    [self.contentWV loadHTMLString:htmlStr baseURL:[NSURL URLWithString:filePath]];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
